/*
 * @Author: tianchunyu
 * @Date: 2020-05-16 11:06:54
 * @LastEditTime: 2020-05-17 18:11:09
 * @LastEditors: Please set LastEditors
 * @Description: the drive of The brush rises and falls
 * @FilePath: \app\xp\driver\syntron\turners_s.h
 */ 
#ifndef _TURNERS_S_H_
#define _TURNERS_S_H_
#include "synron_ls_modbus.h"
#include<stdlib.h>
/*
转向为出厂默认的时候为正 即是抬升的方向
*/
#define TURNERS_angle_speed 20      //转向器转动速度，单位：度/秒
#define TURNERS_ratio       100     //转向器减速机比例 turners:motor
#define TURNERS_part        10000   //转向器电机细分
#define TURNERS_MAX_ANGLE   (96)   //铰链机构转向器最大角度
#define TURNERS_MIX_ANGLE   (-10)   //铰链机构转向器最小角度

#define TURNERS_LIFTS_MOTORS (60.00*TURNERS_ratio/(360.00))     //抬升举平机构度每秒转到机器电机转每分钟


#define TURNERS_DOWN_LIMIT_POSITION     (7-1)   //举平下限位
#define TURNERS_WAIT_POSITION           (8-1)   //举平待机位
#define TURNERS_UP_LIMIT_POSITION       (9-1)   //举平上限位
#define TURN_POWWER                     (18-1)  //驱动器继电器电源控制子板输出控制信号 低电平有效


/*
input singal defination 
*/
#define T_BOARD_ID              (1)   
#define T_INPUT_PIN             (1)   //向左电机输入信号引脚
#define T_HIGH_STATE            (1)   //输入信号高电平状态
#define T_LOW_STATE             (0)    // 输入信号低电平状态
#define T_IPUT_DRIVE_EMG_PIN    (1)   //驱动器紧急停转信号输入引脚 范围 1~4

//tuners class
typedef struct{
    u8 init;    //init state,1=init
    u8 check_zero;  //check zero state
    u8 run; //run state
    u8 res;//reserve
    s32 encode ;//刷子竖直向下为0，抬起方向为正，往里收方向为负
    double angle;
    SYNRO_handler* hinge_hander; //motor object  抬起升降电机
}TURNERS_class;


extern void xp_turners_config(void);
extern int xp_turners_init(u8 port,u32 speed,u8 slave_id);
extern int xp_turners_convert_angle(double angle);
extern int  xp_turners_move_time(double angle ,u16 times_ms);
extern int  xp_turners_move_speed(double angle ,float speed);
extern int xp_turners_stop();
extern int xp_turners_get_encode();
extern double xp_turners_convert_pulsevaule(s32 pulsevaule);
extern int xp_turners_check_zero(void);
extern int xp_turners_set_cur_angle(double angle);
extern int xp_turners_debug(char *type,char *fun,char *param);
extern int xp_turners_acc_dcc_time(u16 times);
extern int xp_turners_find_wait_positon();
extern void xp_turners_error_anction();
#endif